package org.jiucheng.magpiebridge.server.aio.proxy;

import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousSocketChannel;
import java.util.concurrent.atomic.AtomicBoolean;

import org.jiucheng.magpiebridge.server.aio.ClientAttachment;

/**
 * 代理连接附件
 * 
 * @author jiucheng
 *
 */
public class ProxyClientWriteAttachment {
    // 当前在写
    public final AtomicBoolean writed = new AtomicBoolean(false);
    // 代理连接
    private AsynchronousSocketChannel asynchronousSocketChannel;
    // 待写入数据
    private ByteBuffer writeByteBuffer;
    // Client附件
    private ClientAttachment clientAttachment;
    
    public ProxyClientWriteAttachment(AsynchronousSocketChannel asynchronousSocketChannel) {
        this.asynchronousSocketChannel = asynchronousSocketChannel;
    }
    
    public AsynchronousSocketChannel getAsynchronousSocketChannel() {
        return asynchronousSocketChannel;
    }
    
    public ByteBuffer getWriteByteBuffer() {
        return writeByteBuffer;
    }
    
    public ProxyClientWriteAttachment setWriteByteBuffer(ByteBuffer writeByteBuffer) {
        this.writeByteBuffer = writeByteBuffer;
        return this;
    }
    
    public ClientAttachment getClientAttachment() {
        return clientAttachment;
    }
    
    public ProxyClientWriteAttachment setClientAttachment(ClientAttachment clientAttachment) {
        this.clientAttachment = clientAttachment;
        return this;
    }
}
